layui.define(['jquery','layer','form','element'],function(exports){
    var $ = layui.jquery;
    var  layer = layui.layer;
    var form = layui.form();
    var element = layui.element();

    $('#username').bind('keypress',function(event){  
        if(event.keyCode == "13")      
        {  
            $("#btnLogin").click();
        }  
    });

    $('#password').bind('keypress',function(event){  
        if(event.keyCode == "13")      
        {  
            $("#btnLogin").click();
        }  
    });

    $("#btnLogin").click(function(){
        var uname=$("#username").val();
        var upass=$("#password").val();
        if(uname==""){layer.msg("用户名不能为空！");return false;}
        if(upass==""){layer.msg("密码不能为空！");return false;}
        //document.getElementById("form1").submit();
         $.post("/html/common/srv/login.php", $("#form1").serialize(), function (d, e) {
            if(d=="ok"){
                layer.msg("登录成功！");
                setTimeout("location.href='./?t=index'",1000);
            }else{
                layer.msg(d);
            }
        });
    });

    exports('login', {});
});